package mythesis.gui.main;

import java.io.*;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Launcher {

    public static void main(String[] args) {
    	String dir = "";
    	File dir1;
    	try
    	{
    		dir1 = new File (".");
	    	File dir2 = new File ("..");
	    	System.out.println(" cur dir : " + dir1.getCanonicalPath());
	    	System.out.println(" can dir : " + dir2.getCanonicalPath());
	    	
	    	dir = dir1.getCanonicalPath();
	    	System.out.println(" >> :" + dir+"\\src\\mythesis\\gui\\main\\Main.fx");
    	}
    	catch(IOException e)
    	{
    		System.out.println("io : " + e);
    	}

        try {
            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByExtension("java");
            //InputStream is = Launcher.class.FileInputStream(dir+"\\src\\mythesis\\gui\\main\\Main.fx");
            //InputStream is = Launcher.class.getResourceAsStream("../../../../bin/mythesis/gui/main/Main.class");
            //InputStream is = Launcher.class.getResourceAsStream("../../../../src/mythesis/gui/main/Main.fx");
            //InputStream is = Launcher.class.getResourceAsStream("../../../../bin/CustomAI1.xml");
            
            InputStream is = Launcher.class.getResourceAsStream("./Main.fx");
            if (is == null)
            {
            	System.out.println("Null input stream");
            }
            
            InputStreamReader reader = new InputStreamReader(is);
            
            engine.eval("Main.fx");
        } catch (ScriptException ex) {
        	System.out.println(" error : " + ex);
        }
    }
    
}